<template>
<div>
    <h3>Home组件</h3>
    <!-- 实现自动获取焦点 -->
   <input type="text" v-focus>
     <button @click="count+=1">+1</button>
    <input type="text" ref="pi">
  
    <p>{{count}}</p>
</div>  
</template>

<script>
export default {
    name:'Home',
    data(){
        return{
            count:1
        }
    },
    // 自定义指令的声明节点
    directives:{
        focus:{
            mounted(el){
                el.focus()
            },
            updated(el){
                el.focus()
            }
        }
    },
    // 回忆用$nextTick()函数
    created(){
       this.$nextTick(()=>this.$refs.pi.focus())
    }

}
</script>

<style>

</style>